metrics

Section: User Commands (1)
Index Return to Main Contents


0i


0i XcRichText


0.333i
XcRichText - formatted text display widget


0i SYNOPSIS


0.333i
#include <Xc/RichText.h>


0.333i


0.333i
widget = XtCreateManagedWidget(name, xcRichTextWidgetClass);


0i
CLASS HIERARCHY


0.333i
Core -> XmPrimitive -> XcRichText


0i DESCRIPTION


0.333i
XcRichText formats and displays a passage of text. In the default mode, this widget acts much like a limited XmText widget: it displays the contents of its value resource as text in the requested font, wrapping the text to fit the size of the window, and allows text selection with the mouse. Editing is not supported.


0.333i But when the boolean resource rtf is true, the value resource is interpreted in Rich Text Format rather than plain ASCII. RTF is a document interchange format popularized by Microsoft Word. The XcRichText widget uses RTF character and paragraph formatting control words to choose fonts and lay out the text.


0i RESOURCES


0.333i
In addition to the resources defined by superclasses, this widget defines the following:

  (table deleted, sorry)


0.25i XmNfontList
Specifies the translation from RTF character-formatting properties to X fonts.


0.333i Fonts in an RTF document are divided into six font families: roman, swiss, modern, tech, decor, script, and nil.


0.333i The font family, weight, and slant of a run of text are used as the character set, and the corresponding X font from the FontList is used to display the run of text.


0.333i For example, the following resource specification maps roman, swiss, and modern fonts to Times, Helvetica, and Courier and preserves bold and italic attributes.


0.666i *text.fontList: \
0.666i
fixed=nil,\
0.666i
-*-times-medium-r-*-*-*-120-*-*-*-*-iso8859-1=roman,\
0.666i
-*-times-bold-r-*-*-*-120-*-*-*-*-iso8859-1=roman-bold,\
0.666i
-*-times-medium-i-*-*-*-120-*-*-*-*-iso8859-1=roman-italic,\
0.666i -*-times-bold-i-*-*-*-120-*-*-*-*-iso8859-1=roman-bold-italic,\
0.666i -*-helvetica-medium-r-*-*-*-120-*-*-*-*-iso8859-1=swiss,\
0.666i -*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1=swiss-bold,\
0.666i -*-helvetica-medium-o-*-*-*-120-*-*-*-*-iso8859-1=swiss-italic,\
0.666i -*-helvetica-bold-o-*-*-*-120-*-*-*-*-iso8859-1=swiss-bold-italic,\
0.666i -*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1=modern,\
0.666i -*-courier-bold-r-*-*-*-120-*-*-*-*-iso8859-1=modern-bold,\
0.666i -*-courier-medium-o-*-*-*-120-*-*-*-*-iso8859-1=modern-italic,\
0.666i -*-courier-bold-o-*-*-*-120-*-*-*-*-iso8859-1=modern-bold-italic,\
0.666i -*-symbol-medium-r-*-*-*-120-*-*-*-*-adobe-fontspecific=tech

0.25i XmNmotionVerifyCallback
Specifies the list of callbacks that is called when the user clicks on the text or selects some text. The point and mark fields of the XcRichTextCallbackStruct indicate the character offset where the user clicked and/or dragged. This allows applications to respond to mouse clicks on �hot� areas of text.


0.25i XmNmarginHeight
Specifies distance between the top(bottom) of the window and the first(last) line of text.


0.25i XmNmarginWidth
Specifies the distance between the left(right) side of the window and the text.


0.25i XcNrtf
Specifies whether the text is interpreted in RTF or plain text.


0.25i XmNvalue
Specifies the text to display.


0i CALLBACKS


0.333i
A pointer to the following structure is passed to each callback:


0.666i typedef struct{


0.666i
int reason;


0.666i
XEvent *event;


0.666i
 long mark, point;


0.666i  char* value;


0.666i }XcRichTextCallbackStruct;


0.333i
reason  Indicates why the callback was invoked.


0.333i event   Points to the XEvent that triggered the callback.


0.333i mark    Contains the position of the start of the selection.


0.333i point   Contains the position of the end of the selection. If mark is equal to point, the
selection is empty and mark and point are the position where the mouse click occurred.


0.333i value   Points to the widget�s value string resource


0i PUBLIC FUNCTIONS


0.666i
Widget XcCreateRichText( Widget p, String name, ArgList args, Cardinal n);


0.333i Same as XtCreateWidget(name, xcRichTextWidgetClass, p, args, n).


0.666i char *XcRichTextGetString (Widget widget);


0.333i
Returns a newly allocated copy of the value resource.


0.666i long XcRichTextGetLastPosition (Widget widget);


0.333i
Returns the number of bytes in the value resource.


0.666i char *XcRichTextGetSelection (Widget widget, int strip_rtf);


0.333i
Returns a newly allocated copy of the selected text in the widget. Returns 0 if there is no text selected. If strip_rtf is true, RTF formatting codes are removed from the selected text.


0.666i void XcRichTextSetSelection (Widget widget, XmTextPosition first, XmTextPosition last, Time set_time);


0.333i
Selects the text between first and last and makes that text available as the PRIMARY selection as of set_time.


0.666i void XcRichTextClearSelection (Widget widget, Time clear_time);


0.333i
Unhighlights any selected text and disowns all selections.


0.666i Boolean XcRichTextGetSelectionPosition (Widget widget, XmTextPosition *left, XmTextPosition *right);


0.333i
Returns true only if there is a range of text selected. The range is stored in *left and *right.


0.666i long XcRichTextXYToPos (Widget widget, Position x, Position y);


0.333i
Returns the position of the character at the position (x, y) within the widget.


0.666i Boolean XcRichTextPosToXY (Widget widget, long pos, Position *x, Position *y);


0.333i
Locates a character in the window. If the character position is valid, returns true and stores the x and y coordinates of the character in *x and *y.


0i TRANSLATIONS


0.333i
<Btn1Down>: select-start()
<Btn1Motion>: extend-adjust(